import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
       resolvers: [ElementPlusResolver()],
       }),
    Components({
       resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  // 配置代理服务器
  server: {
    proxy: {
    "/dev-api": {
    target: "http://127.0.0.1:19090/system", // 
    rewrite: (p) => p.replace(/^\/dev-api/, ""),
    },
    },
    },
})
//http://localhost:5173/dev-api/sysUser/login -- proxy 此处代理规则，只要接口请求前缀包含dev-api 
// 则转发给http://127.0.0.1:19090/system这个地址，并把dev-api变成空字符串